<template>
  <div>
    <el-table v-loading="loading" :data="auditLogList">
      <el-table-column label="审批类型" align="center" prop="auditLevel" width="120">
        <template slot-scope="scope">
          <div v-if="scope.row.type === 1">
          <span v-if="scope.row.auditLevel === 1">科室审批</span>
          <span v-if="scope.row.auditLevel === 2">管理员审批</span>
          </div>
        </template>
      </el-table-column>
      <el-table-column label="审批人" align="center" prop="auditNickName" width="120"/>
      <el-table-column label="审批状态" align="center" prop="auditStatus" width="100">
        <template slot-scope="scope">
          {{ ['', '同意', '退回', '拒绝'][scope.row.auditStatus] }}
        </template>
      </el-table-column>
      <el-table-column label="操作时间" align="center" prop="remark">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="审批意见" align="center" prop="remark"/>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import { listAuditLog } from '@/api/business/auditLog'
import { parseTime } from '@/utils/ruoyi'

export default {
  props: {
    registerId: null
  },
  data() {
    return {
      // 根路径
      baseURL: process.env.VUE_APP_BASE_API,
      // 遮罩层
      loading: true,
      // 总条数
      total: 0,
      // 审批记录表格数据
      auditLogList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        registerId: null,
        auditUserId: null,
        auditStatus: null,
        remark: null
      },
      dialogShow: true
    }
  },
  watch: {
    registerId: {
      immediate: true,
      handler() {
        this.queryParams.registerId = this.registerId
        this.getList()
      }
    }
  },
  methods: {
    parseTime,
    /** 查询审批记录列表 */
    getList() {
      this.loading = true
      listAuditLog(this.queryParams).then(response => {
        this.auditLogList = response.rows
        this.total = response.total
        this.loading = false
      })
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1
      this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm('queryForm')
      this.handleQuery()
    }
  }
}
</script>
